 @extends("Layout.art")
 @section("content")
 <script type="text/javascript" src="/home/js/jquery-1.8.2.min.js"></script>


 <a class="btn btn-primary" href="/art/create">添加文章</a>   
    <div class="panel panel-default">
    @foreach($res as $vo)
  <div class="panel-body" id="art_{{$vo->id}}">
    {{$vo->title}}
    <a href="/art/{{$vo->id}}" class="btn btn-info">阅读</a>
    <a href="/art/{{$vo->id}}/edit" class="btn btn-info">修改</a>

    <!--   <form action="/art/{{$vo->id}}" method="post" style="display: inline-block;">
            {{csrf_field()}}
            {{ method_field('DELETE') }} -->
            <button type="submit" id="btn" class="btn btn-danger" onclick="return del({{$vo->id}})">删除</button>
       <!--  </form> -->
    </div>
    @endforeach
    </div>
 <script>

 function del(id)
 {
    console.log(this);
         $.ajax({
            type:'GET',
            url:'/demo/del',
            data:{id:id},
            async:true,
            success:function(data){
                if(data ==1){
                    //还有缺陷
                    //$("#btn"+id).removeClass("panel-body");
                    $("#art_"+id).remove();

                }else{
                    alert('删除失败,请稍后再试');
                     return false;
                }    
        }
    });
 }
 </script>

    {!!$res->render()!!}
@endsection